<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<title>Form Elements - Ace Admin</title>

<meta name="description" content="Common form elements and layouts" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

<!-- bootstrap & fontawesome -->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/bootstrap.min.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/font-awesome.min.css" />

<!-- page specific plugin styles -->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/jquery-ui.custom.min.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/chosen.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/datepicker.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/bootstrap-timepicker.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/daterangepicker.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/bootstrap-datetimepicker.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/colorpicker.css" />

<!-- text fonts -->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/ace-fonts.css" />

<!-- ace styles -->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/ace.min.css"
	id="main-ace-style" />

<!--[if lte IE 9]>
			<link rel="stylesheet" href="<%=request.getContextPath()%>/ace/assets/css/ace-part2.min.css" />
		<![endif]-->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/ace-skins.min.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/ace-rtl.min.css" />

<!--[if lte IE 9]>
		  <link rel="stylesheet" href="<%=request.getContextPath()%>/ace/assets/css/ace-ie.min.css" />
		<![endif]-->

<!-- inline styles related to this page -->

<!-- ace settings handler -->


<!-- HTML5shiv and Respond.js for IE8 to support HTML5 elements and media queries -->

<!--[if lte IE 8]>
		<script src="<%=request.getContextPath()%>/ace/assets/js/html5shiv.min.js"></script>
		<script src="<%=request.getContextPath()%>/ace/assets/js/respond.min.js"></script>
		<![endif]-->
<script type="text/javascript" src="${ctx }/static/js/jquery-1.11.0.min.js"></script>	
<script type="text/javascript" src="${ctx }/static/js/ajaxfileupload.js"></script>
</head>

<body class="no-skin">
<div class="breadcrumbs" id="breadcrumbs">

		<ul class="breadcrumb">
			<li><i class="ace-icon fa fa-home home-icon"></i> <a >当前位置</a>
			</li>
			<li><a href="#">新闻动态管理</a></li>
			<li class="active">添加</li>
		</ul>
		<!-- /.breadcrumb -->

	</div>
	<!-- /section:basics/content.breadcrumbs -->
	<div class="page-content">
		<!-- /section:settings.box -->
		<div class="page-content-area">
			<div class="page-header">
				<h4>添加新闻动态</h4>
			</div>
		
			<!-- /.page-header -->

			<div class="row">
				<div class="col-xs-12">
					<!-- PAGE CONTENT BEGINS -->
					<form id="drizzt-table" class="form-horizontal"
						action="<%=request.getContextPath()%>/bsbFirmMoving/add.do"
						method="post">
						<!-- #section:elements.form -->
						  <input type="hidden"  name="queryString" value="${queryString}" />
  						<div class="form-group">
							<label class="col-sm-1 control-label no-padding-right"
								for="form-field-1"> 标题 </label>

							<div class="col-sm-9">
								<input type="text" id="form-field-1"
									placeholder="输入动态 标题"
									name="title"
									class="col-xs-10 col-sm-5" />
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-1 control-label no-padding-right"
								for="form-field-1"> 标签 </label>

							<div class="col-sm-9">
							
							<label for="r1"><input type="radio" id="r1" name="lable" value="动态">&nbsp;动态</label>  
							<label for="r2"><input type="radio"  id="r2"name="lable"  value="快讯">&nbsp;快讯</label>  
							<label for="r3"><input type="radio"  id="r3"name="lable" value="活动">&nbsp;活动</label>  
							<label for="r4"><input type="radio" id="r4" name="lable" value="头条">&nbsp;头条</label>  
							</div>
						</div>
							 <div class="form-group">
							<label class="col-sm-1 control-label no-padding-left"
								for="form-field-1"> 排序 </label>

							<div class="col-sm-2">
								<input
									type="number" id="sortId"
									name="sort"
									placeholder="排序" min="1"
									class="col-xs-10 col-sm-5" value="1" />
							</div>
						</div>
					
						<div class="form-group">
							<label class="col-sm-1 control-label no-padding-right"
								for="form-field-1"> 内容 </label>

								<span class="help-inline col-xs-12 col-sm-7">
									<span class="middle">注：文字内容上传的图片大小总计不超过1M。</span>
								</span>
							<div class="col-sm-9">
								<input type="hidden" name="content" id="content">
								<div id="wang">
								</div>
							</div>
						</div>
						  						
						
										
						<div class="clearfix form-actions">
							<div class="col-md-offset-3 col-md-9">
								<input class="btn btn-info" type="button"  id="sub" onclick="create();"  value="提交" />

								&nbsp; &nbsp; &nbsp;
								<input type="button" class="btn btn-info" onclick="location.href='<%=request.getContextPath()%>/bsbFirmMoving/toList.do?${queryString}'" value="返回" />
							</div>
						</div>
					</form>

					<!-- PAGE CONTENT ENDS -->
				</div>
				<!-- /.col -->
			</div>
			<!-- /.row -->
		</div>
		<!-- /.page-content-area -->
	</div>
	<!-- /.page-content -->
</body>

<!-- basic scripts -->

<!--[if !IE]> -->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/ace.onpage-help.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/docs/assets/js/themes/sunburst.css" />
	
	

<script type="text/javascript">
	window.jQuery
			|| document
					.write("<script src='<%=request.getContextPath()%>/ace/assets/js/jquery.min.js'>"
							+ "<"+"/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='<%=request.getContextPath()%>/ace/assets/js/jquery1x.min.js'>"+"<"+"/script>");
</script>
<![endif]-->
<script type="text/javascript">
	if ('ontouchstart' in document.documentElement)
		document.write("<script src='<%=request.getContextPath()%>/ace/assets/js/jquery.mobile.custom.min.js'>" + "<"+"/script>");
</script>

<script
	src="<%=request.getContextPath()%>/ace/assets/js/bootstrap.min.js"></script>

<!-- the following scripts are used in demo only for onpage help and you don't need them -->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/ace.onpage-help.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/docs/assets/js/themes/sunburst.css" />
<script
	src="<%=request.getContextPath()%>/ace/assets/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/static/js/wangEditor.js"></script>
<script type='text/javascript'>
	var E = window.wangEditor
	
	var editor1 = new E('#wang')
	editor1.customConfig.uploadImgShowBase64 = true
	editor1.customConfig.pasteFilterStyle = true
	editor1.customConfig.pasteIgnoreImg = true	
	editor1.create()
	var timer = null;
	function create() {
		
		$("#content").val(editor1.txt.html());
		
		var title = $("input[name='title']").val();
		var sort = $("#sortId").val();
		var content=$("#content").val();
		 var lable = document.getElementsByName("lable");
		if(title==""){
			alert("产品标题不能为空");
			return false;
		}
	 var b=false;
		 for(var i=0;i<lable.length;i++){
			  if(lable[i].checked==true){
				  b=true;
			  }
		}
		if(b==false){
			alert("标签不能为空");
			return false;
		}
		if(sort==null||sort==""){
			alert("排序为纯数字！");
			return false;
		}
		var reg=/^[0-9]*$/g;
		if(!reg.test(sort)){
			alert("排序为纯数字！");
			return false;
		}
	
		if(content==""){
			alert("内容不能为空");
			return false;
		}
		  $("#sub").attr('disabled', 'disabled');
		  
		  clearTimeout(timer); 
		   timer = setTimeout(function() {
		 $.ajax({
	            //提交数据的类型 POST GET
	            type:"POST",
	            //提交的网址
	            url:"<%=request.getContextPath()%>/bsbFirmMoving/add.do",
	            //提交的数据     data:$('#drizzt-tables').serialize(),// 你的formid
	          //  data:$('#drizzt-tables').serialize(),
	           datatype: "json",
	          data:$('#drizzt-table').serialize(),
	            //成功返回之后调用的函数             
	          beforeSend: function () {
                //3.让提交按钮失效，以实现防止按钮重复点击
                 //4.给用户提供友好状态提示
                 $("#sub").val('提交中');
                 
             },
            
             complete: function () {
                 //
                 $("#sub").removeAttr('disabled');
             },
	           
	         success:function(e){
	        	 if(e.status==1){
	        		  window.location.href = "<%=request.getContextPath()%>/bsbFirmMoving/toList.do";
	        	 }else if(e.status==3){
	        		 alert(e.msg);
	        	 }else{
	        		 alert(e.msg);
	        	 }
		        	
	        	return true;    
	            }, 
	        
	            //调用出错执行的函数
	            error: function(){
	                //请求出错处理
	            }         
	         } );
		   },100);
	}
	
	function sleep(numberMillis) {  
	    var now = new Date();  
	    var exitTime = now.getTime() + numberMillis;  
	    while (true) {  
	        now = new Date();  
	        if (now.getTime() > exitTime)  
	        return;  
	        }  
	} 
</script>
</html>
